package easyexcel.converter;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
public class SexConverter implements Converter<Integer> {
   @Override
   public Class<Integer> supportJavaTypeKey() {
     return Integer.class;
   }
   @Override
   public CellDataTypeEnum supportExcelTypeKey() {
     return CellDataTypeEnum.STRING;
   }
   @Override
   public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
     return "男".equals(cellData.getStringValue()) ? 1 : 0;
   }
   @Override
   public CellData<String> convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
     return new CellData<>(integer.equals(1) ? "男" : "女");
   }
}
